<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>传世心经</title>
</head>
<body>
<script>
function ajax(){ 
    var ajaxData = { 
        type:arguments[0].type || "GET", 
        url:arguments[0].url || "", 
        async:arguments[0].async || "true", 
        data:arguments[0].data || null, 
        dataType:arguments[0].dataType || "text", 
        contentType:arguments[0].contentType || "application/x-www-form-urlencoded", 
        beforeSend:arguments[0].beforeSend || function(){}, 
        success:arguments[0].success || function(){}, 
        error:arguments[0].error || function(){} 
    } 
    ajaxData.beforeSend() 
    var xhr = createxmlHttpRequest();  
    xhr.responseType=ajaxData.dataType; 
    xhr.open(ajaxData.type,ajaxData.url,ajaxData.async);  
    xhr.setRequestHeader("Content-Type",ajaxData.contentType);  
    xhr.send(convertData(ajaxData.data));  
    xhr.onreadystatechange = function() {  
        if (xhr.readyState == 4) {  
        if(xhr.status == 200){ 
            ajaxData.success(xhr.response) 
        }else{ 
            ajaxData.error() 
        }  
        } 
    }  
    } 
    
    function createxmlHttpRequest() {  
    if (window.ActiveXObject) {  
        return new ActiveXObject("Microsoft.XMLHTTP");  
    } else if (window.XMLHttpRequest) {  
        return new XMLHttpRequest();  
    }  
    } 
    
    function convertData(data){ 
    if( typeof data === 'object' ){ 
        var convertResult = "" ;  
        for(var c in data){  
        convertResult+= c + "=" + data[c] + "&";  
        }  
        convertResult=convertResult.substring(0,convertResult.length-1) 
        return convertResult; 
    }else{ 
        return data; 
    } 
    }

    
    var URL = 'http://' + window.location.host + '/redirect.html';
    var params = {
        url: URL
    };
    var jsonData = JSON.stringify(params);
    ajax({ 
        type:"POST", 
        url:"http://heart.csbr.cn/app/openroute/CSBR.Management.AppService.Service.V1.DataService/GetWxUserAuth", //留意域名修改留意域名修改留意域名修改留意域名修改留意域名修改
        //测试http://hearttest.csyaoly.cn
        //正式http://heart.csbr.cn
        dataType:"json", 
        contentType: "application/json",
        data:jsonData, 
        beforeSend:function(){ 
        }, 
        success:function(msg){ 
        if (msg.code == 'SUCC') {
          // alert("操作成功");
          window.location.href = msg.data;
          window.event.returnValue = false;
        } else {
          alert('服务器连接失败！');
        } 
        }, 
        error:function(){ 
          alert('服务器连接失败！'); 
        } 
    })
</script> 
</body>
</html>


